package com.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.service.RegistryService;
import com.service.Vo.RegistryBean;
import com.service.Vo.RegistryTagBean;
import javafx.beans.DefaultProperty;
import jdk.nashorn.internal.parser.JSONParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

@RestController
@RequestMapping("/registry")
public class RegistryController {
    private static final Logger logger = LoggerFactory.getLogger(com.controller.RegistryController.class);
    @Autowired
    private RegistryService registryService;
    private RegistryBean registryBean;

    @RequestMapping("/list")
    @ResponseBody
    public String RegistryList( @PathParam("namespace") String namespace ) throws Exception {
        List<RegistryBean> json = registryService.RegistryList(namespace);
        String jsonString = JSON.toJSONString(json);
        return jsonString;
    };

    @RequestMapping("/tag/{namespace}/{regname}")
    @ResponseBody
    public String RegistryTag ( @PathVariable String namespace, @PathVariable String regname ) throws Exception {
        List<RegistryTagBean> tag = registryService.RegistryTagList(namespace,regname);
        String jsonString = JSON.toJSONString(tag);
        return jsonString;
    }
}


